<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>作用域链</title>
</head>
<body>
    <script>
    // var a = 1
    // function fn () {
    //     var b = a + 1
    //     console.log(b)
    // }
    //     fn()
    /* 作用域链特点自下而上寻找输出变量b时，由于有作用域链所以代码会向上寻找直到找出a变量 */

    var a = 1
    function fn () {
        var b = a + 1
        console.log(b)
    }
    console.dir(fn)


    </script>
</body>
</html>